package com.gjh.study.basic.thread;

import java.util.Date;

/**
 * @author guangjh
 * @version 1.0
 * @date 2020/7/7 16:17
 */
public class MyRunnable implements Runnable {
    private String command;

    public MyRunnable(String s) {
        this.command = s;
    }

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName() + " start time = " + new Date());
        processCommand();
        System.out.println(Thread.currentThread().getName() + " end time = " + new Date());
    }

    private void processCommand() {
        try {
            Thread.sleep(5000);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public String toString() {
        return this.command;
    }
}
